<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <script type="text/javascript" src="../../inc/ctx.jsp"></script>
        <script type="text/javascript" src="../js/g.js"></script>
        <link href="../css/com.css" type="text/css" rel="stylesheet"/>
        <style>
            img.s1{width:100px;border:1px #EFEFEF solid;padding:1px;}
            #datalist tr td{text-align:center;}
        </style>
    </head>
    <body>
        <div id="panel"><h3 class="s1">角色列表</h3></div>
        <div class="databox">
            <table border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <th width="10%">ROLEID</th>
                    <th width="20%">角色名称</th>
                    <th width="34%">角色描述</th>
                    <th width="36%"> 操作</th>
                </tr>
                <tbody class="tbchg" id="datalist"></tbody>
            </table>
        </div>
        <div class="page" id="page"></div>

        <div style="display:block;clear:both;width:98%;height:50px;">&nbsp;</div>





        <!-- 数据处理 -->

        <script id="listTpl" type="text/html">
            {%  for(var k in list){ var e = list[k]; %}
        <tr>
            <td>{%=e.roleid%}</td>
            <td>{%=e.rolename%}</td>
            <td>{%=e.remark%}</td>
            <td>
                {% if(e.roleid>1){ %}
                <a  href="#edit" onclick="ROLE.edit('{%=e.roleid%}');">编辑</a> | 
                <a  href="javascript:;" onclick="ROLE.del('{%=e.roleid%}');">删除</a>
                {% }else{ %}
                超级管理员角色, 不得删除.
                {% } %}
            </td>
        </tr>
        {% } %}
    </script>

    <script type="text/javascript">
        var $lsout = $('#datalist');
        var par={};
        var ROLE={
            list:function(){
                var ls =20;
                TxBox.wait();
                $.get('../app/admin/list_role.shtm', 'ls='+ls+'&t='+ut.r(),
                function(x){
                    $lsout.html(template.render('listTpl',x));
                    TxBox.hide();
                }
            );
            },
            del:function(id){
                if(!window.confirm("确定删除么?执行后关联的管理员信息将被删除."))return;
                $.get('../app/admin/delete_role.shtm?t='+ut.r(), "roleid="+id, function(x){
                    var r = $.trim(x);
                    if(r=='ok'){
                        ut.m('删除成功.');
                        ROLE.list();
                    }else{
                        ut.m('删除失败. '+r);
                    }
                });
            },
            edit:function(id){
                ut.reload('mgrole_edit.html?roleid='+id+'&t='+ut.r());
            }
        };

        ROLE.list();
    </script>
</body>
</html>
